package com.zsrt.java.day20161226.xww.demo1;

import java.util.Scanner;

public class Claculate {

	public static int jia(int x, int y) {
		return x + y;
	}

	public static int jian(int x, int y) {
		return x - y;
	}

	public static int cheng(int x, int y) {
		return x * y;
	}

	public static int chu(int x, int y) {
		return x / y;
	}

	public static int qiumo(int x, int y) {
		return x % y;
	}

	public static int cal(String flag, int x, int y) {
		int result = 0;
		if (flag.equals("+")) {
			result = jia(x, y);

		} else if (flag.equals("-")) {
			result = jian(x, y);

		} else if (flag.equals("*")) {
			result = cheng(x, y);

		} else if (flag.equals("/")) {
			result = chu(x, y);

		} else if (flag.equals("%")) {
			result = qiumo(x, y);
		}
		return result;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			System.out.println("请输入符号...");
			String c = sc.next();
			if (c.equals("quit")) {
				break;
			}
			System.out.println("请输入第1个数...");
			int a = sc.nextInt();

			System.out.println("请输入第2个数...");
			int b = sc.nextInt();
			int aa = cal(c, a, b);
			System.out.println(aa);
		}
		sc.close();
	}
}
